package javabase.schoolwork.day6_07;

/**
 * @author fance
 * @date 2018/6/7 20:24
 */

class ThreadIsAlive implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + " " + i);
        }
    }
}
public class ThreadAlive {
    public static void main(String[] args) {
        ThreadIsAlive threadIsAlive = new ThreadIsAlive();

        Thread thread = new Thread(threadIsAlive,"A");
        System.out.println("before " + thread.isAlive());
        thread.start();
        System.out.println("after " + thread.isAlive());


        for (int i = 0; i < 3; i++) {
            System.out.println("main run " + i);
        }

        System.out.println("finally " + thread.isAlive());
    }
}
